package day20171213;

import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by Administrator on 2017-12-13.
 */
public class Test {

    public static void main(String[] args) {

        Map<String, Integer> map = new HashMap<>();


        // 读文件
        BufferedReader reader = null;

        try {
             reader = new BufferedReader(
                    new FileReader("D:\\names.txt"));


            String stuNo = "";

            while ((stuNo = reader.readLine()) != null) {


                map.put(stuNo, 0);
            }


        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {

            try {
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }


        File file = new File("D:\\16信本2班Java作业一");

        File[] files = file.listFiles();
        for (File  f : files){

//            System.out.println(getNo(f.getName()));
            map.put(getNo(f.getName()), 1);
        }

        for (Map.Entry<String, Integer> entry : map.entrySet()){

            if(entry.getValue() == 0){
                System.out.println(entry.getKey());
            }
        }

    }

    static String getNo(String fileName){

        String no = null;

        Matcher matcher = Pattern.compile("信本2班(1606\\d+)").matcher(fileName);
        while(matcher.find()){

            no = matcher.group(1);
        }

        return no;
    }
}
